<?php

use yii\db\Migration;

class m171220_015100_create_customer_goods extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }

    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->createTable('{{%customer_goods}}',[
                'customer_id' => $this->integer()->defaultValue(0)->comment('会员id'),
                'goods_id' => $this->integer(0)->defaultValue(0)->comment('课程商品id'),
            ]);
            $this->addCommentOnTable('{{%customer_goods}}','老生免分成课程');
        }
    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->dropTable('{{%customer_goods}}');
        }
    }
}
